package com.net.wanjian.networkhospitalmanager.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.adapter.base.RecyclerBaseAdapter;
import com.net.wanjian.networkhospitalmanager.net.HttpUtil;
import com.net.wanjian.networkhospitalmanager.utils.PicassoUtil;
import com.net.wanjian.networkhospitalmanager.utils.SharedXmlUtil;

import java.util.ArrayList;

/**
 * Description:
 * Created by lidongcai on 17/5/18.
 * Email:  lidongcaiocc@163.com
 */

public class ShowLabOperationAdapter  extends RecyclerBaseAdapter<String,ShowLabOperationAdapter.ViewHolder> {

    private Context mContext;
    private ArrayList<String> imageUrls; //图片id集合

    public ShowLabOperationAdapter(Context mContext, ArrayList<String> imageUrls) {
        super(mContext);
        this.mContext = mContext;
        this.imageUrls = imageUrls;
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_show_lab_operation, null);
        return new ViewHolder(view);
    }


    @Override
    public void onBindViewHolder(ViewHolder holder, String item, int position) {
        holder.setImageView(imageUrls.get(position));
    }

    @Override
    public int getItemCount() {
        return imageUrls == null ? 0:imageUrls.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;

        public ViewHolder(View itemView) {
            super(itemView);

            imageView = (ImageView) itemView.findViewById(R.id.item_show_lab_photo_iv);
        }

        public void setImageView(String imageID){
            //加载网络图片
            PicassoUtil.loadImage(mContext,HttpUtil.getOperationDevicePhoto(imageID, SharedXmlUtil.getInstance().getHospitalId()),
                    R.mipmap.logo,imageView);
        }
    }
}
